package net.sx.minemodule.mvp.presenters;

import com.kedll.library.mvp.AbstractRefreshPresenter;
import com.kedll.library.mvp.RefreshingView;

import net.sx.minemodule.R;
import net.sx.minemodule.mvp.bean.IntegralRecordModel;

import io.reactivex.Observable;

/**
 * add shibo.zheng
 * 19/06/14
 * 历史积分记录presenter
 */

public class MineIntegralRecordPresenter extends AbstractRefreshPresenter<RefreshingView> {
    private String integralType;

    public MineIntegralRecordPresenter(RefreshingView mView) {
        super(mView);
        emptyItem.setResId(R.mipmap.mine_no_message);
        emptyItem.setContent("暂无消息");
    }

    @Override
    protected void fetchData(boolean isLoadMore) {
        addSubscription(Observable.range(0, 10)
        .map(integer -> {
            /*IntegralRecordModel integralRecord = new IntegralRecordModel();
            integralRecord.setRecordTime("2019-04-01~2019-04-30");
            integralRecord.setRecordNum("1500");*/
            return getRecordData();
        })
        .toList()
        .subscribe(integralRecordModels -> parserData(isLoadMore, integralRecordModels)));
    }

    public void setRecordDataType(String integralType) {
        this.integralType = integralType;
    }

    public IntegralRecordModel getRecordData() {
        IntegralRecordModel integralRecord = new IntegralRecordModel();
        if ("expiredIntegral".equals(integralType)) {   //30天内过期积分
            integralRecord.setRecordTime("2019-06-22");
            integralRecord.setRecordDate("过期");
            integralRecord.setRecordInfo("积分");
            integralRecord.setRecordNum("1500");
        } else if ("integralRecording".equals(integralType)) {  //历史积分记录
            integralRecord.setRecordTime("2018-01-01~2018-12-31");
            integralRecord.setRecordDate("");
            integralRecord.setRecordInfo("今年累计获得积分");
            integralRecord.setRecordNum("1200");
        } else if ("integralInfo".equals(integralType)) {   //积分明细
            integralRecord.setRecordTime("2018-06-03");
            integralRecord.setRecordDate("13:20");
            integralRecord.setRecordInfo("消费1500元  获得积分");
            integralRecord.setRecordNum("+20");
        }
        return integralRecord;
    }
}
